<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串数组等</title>
</head>
<body>

</body>
<script>
    //反引号更容易实现字符串拼接.

    let a = "abc";
    let b = 'abc';
    let c = `abc`;

    let m = 190;
    let str = '这件衣服:' + m + "元";
    let str2 = `这件衣服:${m}元`
    console.log(str);
    console.log(str2);


    //字符串常用方法:
    let str3 = "abcdefghddfaghdfg";
    var result = str3.substr(1, 5); //类似于数据库的limit
    console.log(result);
    var result2 = str3.substring(3, 5); //类似于java中的截取
    console.log(result2);


    //数组
    let arr = [1, "d", 323, "啊打法但是"];
    console.log(arr.length);
    console.log(typeof arr[1]);
    for (let ele of arr) {
        console.log(ele);
    }
    for (let index in arr) {
        console.log(index);
    }


    //日期:
    let date = new Date();
    console.log(date.toLocaleTimeString());
    console.log(date.toLocaleDateString());
    console.log(date.getDate());
    console.log(date.getMilliseconds());


    //数学
    let num = 12.3;
    let number = Math.round(num);
    console.log(number);
    console.log(Math.abs(num));
    console.log(Math.ceil(num));
    console.log(Math.exp(num));



    //全局函数
    //即可以直接调用的函数

    //字符串变数字(从左到右解析,直到非int数字为止.)
    let size = "100.32pxdasf";
    let i = parseInt(size);
    //可以解析小数
    let j = parseFloat(size);
    console.log(i);
    console.log(j);

    //字符串编码和解码
    //1.url编码(网络传输数据支持url编码).方便数据存储和传输
    let name ="嘎达发";
    let s1 = encodeURI(name);
    console.log(s1);

    let s2 = decodeURI(s1);
    console.log(s2);

    //解码:方便人查看



</script>
</html>